﻿using System;
using System.Collections.Generic;
using System.Web;
using System.IO;

namespace ExportBookmark
{
    /// <summary>
    /// Summary description for BookyFileHandler
    /// </summary>
    public class BookyFileHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            //context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            Encryption ec = new Encryption();

            //FileInfo file = new FileInfo(ec.Decrypt(context.Request["b"]));
            FileInfo file = new FileInfo(Globals.BookmarkFileLocation + ec.Decrypt(context.Request["b"]));
            context.Response.AppendHeader("content-disposition", "attachment; filename=" + file.Name);
            context.Response.ContentType = "application/booky";
            context.Response.WriteFile(file.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}